#!/bin/sh

if /usr/bin/test ! -e "/lib/firmware/$FIRMWARE" ; then
    /usr/bin/mm_command message_output 'err', "missing firmware /lib/firmware/$FIRMWARE."
    exit 1
fi

if /usr/bin/test ! -e "/sys$DEVPATH/data" ||
   /usr/bin/test ! -e "/sys$DEVPATH/loading"    ; then
    /usr/bin/mm_command message_output 'err', "missing firmware loader sysfs interface for /sys$DEVPATH."
    exit 1
fi

/bin/echo 1 > /sys$DEVPATH/loading
/bin/cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data
/bin/echo 0 > /sys$DEVPATH/loading

exit 0
